<?php
	session_start();
	include_once('config.php');
	include_once('SystemOneAPI.php');
	$api_service_list = "http://systemone.uplb.edu.ph/api/auth/";
	$api = new SystemOneAPI($api_service_list, API_USERNAME, API_PASSWORD);
	
	$login_params = array( );
	$login_params['username'] = $_POST['username'];
	$login_params['password'] = $_POST['password'];
	$result = $api->execute('login', $login_params);

	if ($result) {
		$_SESSION['sessionInfo'] = $api->getSessionInfo();
		$api->close();
		header('Location: main.php');

	} else {
		$error_message = $api->getLastError();
		$api->close();
		
		echo '<br />'.$error_message;
		//header('Location: login.php');
	}

?>